package com.awise.app.cloudy.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.awise.R;
import com.awise.base.BaseActivity;

/**
 * @author Administrator
 * @time 2018/3/3 20:54
 * @des ${TODO}
 * @updateAuthor $Author$
 * @updateDate $Date$
 * @updateDes ${TODO}
 */
public class RepeatDayActivity extends BaseActivity implements View.OnClickListener {
    private ImageView cb_every_week_1,cb_every_week_2,cb_every_week_3,
            cb_every_week_4,cb_every_week_5,cb_every_week_6,cb_every_week_7;
    private RelativeLayout rl_every_week_1,rl_every_week_2,rl_every_week_3,rl_every_week_4,
            rl_every_week_5,rl_every_week_6,rl_every_week_7;
    private boolean week_1,week_2,week_3,week_4,week_5,week_6,week_7;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.repeat_day_layout);
        initview();
        week_7 =getIntent().getBooleanExtra("week_7",false);
        week_1 =getIntent().getBooleanExtra("week_1",false);
        week_2 =getIntent().getBooleanExtra("week_2",false);
        week_3 =getIntent().getBooleanExtra("week_3",false);
        week_4 =getIntent().getBooleanExtra("week_4",false);
        week_5 =getIntent().getBooleanExtra("week_5",false);
        week_6 =getIntent().getBooleanExtra("week_6",false);
        cb_every_week_7.setVisibility(week_7?View.VISIBLE:View.INVISIBLE);
        cb_every_week_1.setVisibility(week_1?View.VISIBLE:View.INVISIBLE);
        cb_every_week_2.setVisibility(week_2?View.VISIBLE:View.INVISIBLE);
        cb_every_week_3.setVisibility(week_3?View.VISIBLE:View.INVISIBLE);
        cb_every_week_4.setVisibility(week_4?View.VISIBLE:View.INVISIBLE);
        cb_every_week_5.setVisibility(week_5?View.VISIBLE:View.INVISIBLE);
        cb_every_week_6.setVisibility(week_6?View.VISIBLE:View.INVISIBLE);
    }

    private void initview() {
        //设置各个控件的点击响应
        TextView tv_back= (TextView)this.findViewById(R.id.tv_back);
        tv_back.setOnClickListener(this);
        cb_every_week_1= (ImageView)this.findViewById(R.id.cb_every_week_1);
        cb_every_week_2= (ImageView)this.findViewById(R.id.cb_every_week_2);
        cb_every_week_3= (ImageView)this.findViewById(R.id.cb_every_week_3);
        cb_every_week_4= (ImageView)this.findViewById(R.id.cb_every_week_4);
        cb_every_week_5= (ImageView)this.findViewById(R.id.cb_every_week_5);
        cb_every_week_6= (ImageView)this.findViewById(R.id.cb_every_week_6);
        cb_every_week_7= (ImageView)this.findViewById(R.id.cb_every_week_7);
        rl_every_week_1= (RelativeLayout)this.findViewById(R.id.rl_every_week_1);
        rl_every_week_2= (RelativeLayout)this.findViewById(R.id.rl_every_week_2);
        rl_every_week_3= (RelativeLayout)this.findViewById(R.id.rl_every_week_3);
        rl_every_week_4= (RelativeLayout)this.findViewById(R.id.rl_every_week_4);
        rl_every_week_5= (RelativeLayout)this.findViewById(R.id.rl_every_week_5);
        rl_every_week_6= (RelativeLayout)this.findViewById(R.id.rl_every_week_6);
        rl_every_week_7= (RelativeLayout)this.findViewById(R.id.rl_every_week_7);
        rl_every_week_1.setOnClickListener(this);
        rl_every_week_2.setOnClickListener(this);
        rl_every_week_3.setOnClickListener(this);
        rl_every_week_4.setOnClickListener(this);
        rl_every_week_5.setOnClickListener(this);
        rl_every_week_6.setOnClickListener(this);
        rl_every_week_7.setOnClickListener(this);
        //显示PopupWindow
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_back:
                setResult(RESULT_OK,getIntent()
                        .putExtra("week_7",week_7)
                        .putExtra("week_1",week_1)
                        .putExtra("week_2",week_2)
                        .putExtra("week_3",week_3)
                        .putExtra("week_4",week_4)
                        .putExtra("week_5",week_5)
                        .putExtra("week_6",week_6));
                finish();
                break;
            case R.id.rl_every_week_7:
                week_7=week_7?false:true;
                cb_every_week_7.setVisibility(week_7?View.VISIBLE:View.INVISIBLE);
                break;

            case R.id.rl_every_week_1:
                week_1=week_1?false:true;
                cb_every_week_1.setVisibility(week_1?View.VISIBLE:View.INVISIBLE);
                break;
            case R.id.rl_every_week_2:
                week_2=week_2?false:true;
                cb_every_week_2.setVisibility(week_2?View.VISIBLE:View.INVISIBLE);
                break;
            case R.id.rl_every_week_3:
                week_3=week_3?false:true;
                cb_every_week_3.setVisibility(week_3?View.VISIBLE:View.INVISIBLE);
                break;
            case R.id.rl_every_week_4:
                week_4=week_4?false:true;
                cb_every_week_4.setVisibility(week_4?View.VISIBLE:View.INVISIBLE);
                break;
            case R.id.rl_every_week_5:
                week_5=week_5?false:true;
                cb_every_week_5.setVisibility(week_5?View.VISIBLE:View.INVISIBLE);
                break;
            case R.id.rl_every_week_6:
                week_6=week_6?false:true;
                cb_every_week_6.setVisibility(week_6?View.VISIBLE:View.INVISIBLE);
                break;
        }
    }
}
